/*
 * AltoSettings.cpp
 *
 *  Created on: 2009/02/12
 *      Author: Yongshik Cho
 */

#include "AltoSettings.h"
#include "../Exception.h"
#include "../LoggerableManager.h"

const String AltoSettings::_DEFAULT_SETTINGS_FILE	= _T("alto2d.settings.xml");

const std::string AltoSettings::_SETTINGS_TAG		= "Alto2DSettings";
const std::string AltoSettings::_VENDOR_TAG 		= "Vendor";
const std::string AltoSettings::_VERSION_TAG		= "Version";
const std::string AltoSettings::_RENDERER_TAG		= "Renderer";
const std::string AltoSettings::_RENDER_DEVICE_TAG	= "RenderDevice";
const std::string AltoSettings::_AUDIO_DEVICE_TAG	= "AudioDevice";
const std::string AltoSettings::_TITLE_TAG			= "Title";
const std::string AltoSettings::_POSX_TAG			= "PosX";
const std::string AltoSettings::_POSY_TAG			= "PosY";
const std::string AltoSettings::_WIDTH_TAG			= "Width";
const std::string AltoSettings::_HEIGHT_TAG			= "Height";
const std::string AltoSettings::_BITSPIXEL_TAG		= "BitsPixel";
const std::string AltoSettings::_FULLSCREEN_TAG		= "Fullscreen";
const std::string AltoSettings::_RESIZABLE_TAG		= "Resizable";
const std::string AltoSettings::_VREFRESH_TAG		= "VRefresh";
const std::string AltoSettings::_LOGGING_TAG		= "Logging";
const std::string AltoSettings::_CONTROL_POINT_SIZE_TAG		= "ControlPointSize";
const std::string AltoSettings::_CONTROL_POINT_COLOR_TAG	= "ControlPointColor";
const std::string AltoSettings::_CENTER_POINT_SIZE_TAG		= "CenterPointSize";
const std::string AltoSettings::_CENTER_POINT_COLOR_TAG		= "CenterPointColor";
const std::string AltoSettings::_COLLIDABLE_COLOR_TAG		= "CollidableColor";
const std::string AltoSettings::_COLLIDABLE_POINT_SIZE_TAG	= "CollidablePointSize";
const std::string AltoSettings::_COLLIDABLE_POINT_COLOR_TAG	= "CollidablePointColor";
const std::string AltoSettings::_ORIGIN_POINT_SIZE_TAG		= "OriginPointSize";
const std::string AltoSettings::_ORIGIN_POINT_COLOR_TAG		= "OriginPointColor";
const std::string AltoSettings::_ATTACHMENT_POINT_SIZE_TAG	= "AttachmentPointSize";
const std::string AltoSettings::_ATTACHMENT_POINT_COLOR_TAG	= "AttachmentPointColor";

const std::string AltoSettings::_DIRECTX9_TAG		= "DirectX9";
const std::string AltoSettings::_OPENGL_TAG			= "OpenGL";
const std::string AltoSettings::_OPENAL_TAG			= "OpenAL";
const std::string AltoSettings::_TRUE_TAG			= "true";
const std::string AltoSettings::_FALSE_TAG			= "false";


DeviceSettings* AltoSettings::readSettings()
{
#ifdef UNICODE
	char mbstr[512]; memset(mbstr, 0, 512);
	::WideCharToMultiByte(CP_ACP, 0, _DEFAULT_SETTINGS_FILE.c_str(), (int32)_DEFAULT_SETTINGS_FILE.size(), mbstr, 512, 0, 0);
	TiXmlDocument* doc = new TiXmlDocument(mbstr);
#else
	TiXmlDocument* doc = new TiXmlDocument(_DEFAULT_SETTINGS_FILE.c_str());
#endif

	if(!doc)
		AltoThrow(Exception::ERR_MEMORY);

	if(!doc->LoadFile(TIXML_ENCODING_UTF8))
		return 0;

	return parseSettings(doc->FirstChildElement(_SETTINGS_TAG.c_str()));
}

void AltoSettings::writeSettings(DeviceSettings* settings)
{
	char mbstr[512]; memset(mbstr, 0, 512);
#ifdef UNICODE
	::WideCharToMultiByte(CP_ACP, 0, _DEFAULT_SETTINGS_FILE.c_str(), (int32)_DEFAULT_SETTINGS_FILE.size(), mbstr, 512, 0, 0);
	TiXmlDocument* doc = new TiXmlDocument(mbstr);
#else
	TiXmlDocument* doc = new TiXmlDocument(_DEFAULT_SETTINGS_FILE.c_str());
#endif
	if(!doc)
		AltoThrow(Exception::ERR_MEMORY);

	char str[256];


	TiXmlElement item(_SETTINGS_TAG.c_str());

	TiXmlElement* node = new TiXmlElement(_VENDOR_TAG.c_str());
	if(!node)
		AltoThrow(Exception::ERR_MEMORY);

	TiXmlText* text = new TiXmlText(settings->vendor.c_str());
	node->InsertEndChild((const TiXmlNode&)*text);
	item.InsertEndChild((const TiXmlNode&)*node);

	node = new TiXmlElement(_VERSION_TAG.c_str());
	if(!node)
		AltoThrow(Exception::ERR_MEMORY);

	text = new TiXmlText(settings->version.c_str());
	node->InsertEndChild((const TiXmlNode&)*text);
	item.InsertEndChild((const TiXmlNode&)*node);

	node = new TiXmlElement(_RENDERER_TAG.c_str());
	if(!node)
		AltoThrow(Exception::ERR_MEMORY);

	text = new TiXmlText(settings->renderer.c_str());
	node->InsertEndChild((const TiXmlNode&)*text);
	item.InsertEndChild((const TiXmlNode&)*node);

	node = new TiXmlElement(_RENDER_DEVICE_TAG.c_str());
	if(!node)
		AltoThrow(Exception::ERR_MEMORY);

	text = new TiXmlText(settings->renderdevice.c_str());
	node->InsertEndChild((const TiXmlNode&)*text);
	item.InsertEndChild((const TiXmlNode&)*node);

	node = new TiXmlElement(_AUDIO_DEVICE_TAG.c_str());
	if(!node)
		AltoThrow(Exception::ERR_MEMORY);

	text = new TiXmlText(settings->audiodevice.c_str());
	node->InsertEndChild((const TiXmlNode&)*text);
	item.InsertEndChild((const TiXmlNode&)*node);

	node = new TiXmlElement(_TITLE_TAG.c_str());
	if(!node)
		AltoThrow(Exception::ERR_MEMORY);

#ifdef UNICODE
	::WideCharToMultiByte(CP_UTF8, 0, settings->title.c_str(), (int32)(settings->title.size()), mbstr, 512, 0, 0);
	text = new TiXmlText(mbstr);
#else
	text = new TiXmlText(settings->title.c_str());
#endif

	text->SetCDATA(true);
	node->InsertEndChild((const TiXmlNode&)*text);
	item.InsertEndChild((const TiXmlNode&)*node);

	node = new TiXmlElement(_POSX_TAG.c_str());
	if(!node)
		AltoThrow(Exception::ERR_MEMORY);

	text = new TiXmlText(itoa(settings->x, str, 10));
	node->InsertEndChild((const TiXmlNode&)*text);
	item.InsertEndChild((const TiXmlNode&)*node);

	node = new TiXmlElement(_POSY_TAG.c_str());
	if(!node)
		AltoThrow(Exception::ERR_MEMORY);

	text = new TiXmlText(itoa(settings->y, str, 10));
	node->InsertEndChild((const TiXmlNode&)*text);
	item.InsertEndChild((const TiXmlNode&)*node);

	node = new TiXmlElement(_WIDTH_TAG.c_str());
	if(!node)
		AltoThrow(Exception::ERR_MEMORY);

	text = new TiXmlText(itoa(settings->width, str, 10));
	node->InsertEndChild((const TiXmlNode&)*text);
	item.InsertEndChild((const TiXmlNode&)*node);

	node = new TiXmlElement(_HEIGHT_TAG.c_str());
	if(!node)
		AltoThrow(Exception::ERR_MEMORY);

	text = new TiXmlText(itoa(settings->height, str, 10));
	node->InsertEndChild((const TiXmlNode&)*text);
	item.InsertEndChild((const TiXmlNode&)*node);

	node = new TiXmlElement(_BITSPIXEL_TAG.c_str());
	if(!node)
		AltoThrow(Exception::ERR_MEMORY);

	text = new TiXmlText(itoa(settings->bitspixel, str, 10));
	node->InsertEndChild((const TiXmlNode&)*text);
	item.InsertEndChild((const TiXmlNode&)*node);

	node = new TiXmlElement(_FULLSCREEN_TAG.c_str());
	if(!node)
		AltoThrow(Exception::ERR_MEMORY);

	if(settings->fullscreen)
		text = new TiXmlText(_TRUE_TAG.c_str());
	else
		text = new TiXmlText(_FALSE_TAG.c_str());
	node->InsertEndChild((const TiXmlNode&)*text);
	item.InsertEndChild((const TiXmlNode&)*node);

	node = new TiXmlElement(_RESIZABLE_TAG.c_str());
	if(!node)
		AltoThrow(Exception::ERR_MEMORY);

	if(settings->resizable)
		text = new TiXmlText(_TRUE_TAG.c_str());
	else
		text = new TiXmlText(_FALSE_TAG.c_str());
	node->InsertEndChild((const TiXmlNode&)*text);
	item.InsertEndChild((const TiXmlNode&)*node);

	node = new TiXmlElement(_LOGGING_TAG.c_str());
	if(!node)
		AltoThrow(Exception::ERR_MEMORY);

	if(settings->logging)
		text = new TiXmlText(_TRUE_TAG.c_str());
	else
		text = new TiXmlText(_FALSE_TAG.c_str());
	node->InsertEndChild((const TiXmlNode&)*text);
	item.InsertEndChild((const TiXmlNode&)*node);

	node = new TiXmlElement(_VREFRESH_TAG.c_str());
	if(!node)
		AltoThrow(Exception::ERR_MEMORY);

	text = new TiXmlText(itoa(settings->vrefresh, str, 10));
	node->InsertEndChild((const TiXmlNode&)*text);
	item.InsertEndChild((const TiXmlNode&)*node);

	node = new TiXmlElement(_CONTROL_POINT_SIZE_TAG.c_str());
	if(!node)
		AltoThrow(Exception::ERR_MEMORY);

	text = new TiXmlText(itoa(settings->control_point_size, str, 10));
	node->InsertEndChild((const TiXmlNode&)*text);
	item.InsertEndChild((const TiXmlNode&)*node);

	node = new TiXmlElement(_CONTROL_POINT_COLOR_TAG.c_str());
	if(!node)
		AltoThrow(Exception::ERR_MEMORY);

	text = new TiXmlText(itoa(settings->control_point_color.getRGBA(), str, 16));
	node->InsertEndChild((const TiXmlNode&)*text);
	item.InsertEndChild((const TiXmlNode&)*node);

	node = new TiXmlElement(_CENTER_POINT_SIZE_TAG.c_str());
	if(!node)
		AltoThrow(Exception::ERR_MEMORY);

	text = new TiXmlText(itoa(settings->center_point_size, str, 10));
	node->InsertEndChild((const TiXmlNode&)*text);
	item.InsertEndChild((const TiXmlNode&)*node);

	node = new TiXmlElement(_CENTER_POINT_COLOR_TAG.c_str());
	if(!node)
		AltoThrow(Exception::ERR_MEMORY);

	text = new TiXmlText(itoa(settings->center_point_color.getRGBA(), str, 16));
	node->InsertEndChild((const TiXmlNode&)*text);
	item.InsertEndChild((const TiXmlNode&)*node);

	node = new TiXmlElement(_COLLIDABLE_COLOR_TAG.c_str());
	if(!node)
		AltoThrow(Exception::ERR_MEMORY);

	text = new TiXmlText(itoa(settings->collidable_color.getRGBA(), str, 16));
	node->InsertEndChild((const TiXmlNode&)*text);
	item.InsertEndChild((const TiXmlNode&)*node);

	node = new TiXmlElement(_COLLIDABLE_POINT_SIZE_TAG.c_str());
	if(!node)
		AltoThrow(Exception::ERR_MEMORY);

	text = new TiXmlText(itoa(settings->collidable_point_size, str, 16));
	node->InsertEndChild((const TiXmlNode&)*text);
	item.InsertEndChild((const TiXmlNode&)*node);

	node = new TiXmlElement(_COLLIDABLE_POINT_COLOR_TAG.c_str());
	if(!node)
		AltoThrow(Exception::ERR_MEMORY);

	text = new TiXmlText(itoa(settings->collidable_point_color.getRGBA(), str, 16));
	node->InsertEndChild((const TiXmlNode&)*text);
	item.InsertEndChild((const TiXmlNode&)*node);

	node = new TiXmlElement(_ORIGIN_POINT_SIZE_TAG.c_str());
	if(!node)
		AltoThrow(Exception::ERR_MEMORY);

	text = new TiXmlText(itoa(settings->origin_point_size, str, 16));
	node->InsertEndChild((const TiXmlNode&)*text);
	item.InsertEndChild((const TiXmlNode&)*node);

	node = new TiXmlElement(_ORIGIN_POINT_COLOR_TAG.c_str());
	if(!node)
		AltoThrow(Exception::ERR_MEMORY);

	text = new TiXmlText(itoa(settings->origin_point_color.getRGBA(), str, 16));
	node->InsertEndChild((const TiXmlNode&)*text);
	item.InsertEndChild((const TiXmlNode&)*node);

	node = new TiXmlElement(_ATTACHMENT_POINT_SIZE_TAG.c_str());
	if(!node)
		AltoThrow(Exception::ERR_MEMORY);

	text = new TiXmlText(itoa(settings->attachment_point_size, str, 16));
	node->InsertEndChild((const TiXmlNode&)*text);
	item.InsertEndChild((const TiXmlNode&)*node);

	node = new TiXmlElement(_ATTACHMENT_POINT_COLOR_TAG.c_str());
	if(!node)
		AltoThrow(Exception::ERR_MEMORY);

	text = new TiXmlText(itoa(settings->attachment_point_color.getRGBA(), str, 16));
	node->InsertEndChild((const TiXmlNode&)*text);
	item.InsertEndChild((const TiXmlNode&)*node);

	TiXmlDeclaration decl("1.0", "UTF-8", "");
	//insert declaration

	doc->InsertEndChild(decl);
	doc->InsertEndChild(item);
	doc->SaveFile();
}

DeviceSettings* AltoSettings::parseSettings(TiXmlElement* element)
{
	if(!element)
		return 0;

	char* sVendor = (char*)element->Attribute(_VENDOR_TAG.c_str());
	char* sVersion = (char*)element->Attribute(_VERSION_TAG.c_str());
	char* sRenderer = (char*)element->Attribute(_RENDERER_TAG.c_str());
	char* sRenderDevice = (char*)element->Attribute(_RENDER_DEVICE_TAG.c_str());
	char* sAudioDevice = (char*)element->Attribute(_AUDIO_DEVICE_TAG.c_str());
	char* sTitle = (char*)element->Attribute(_TITLE_TAG.c_str());
	char* sFullscreen = (char*)element->Attribute(_FULLSCREEN_TAG.c_str());
	char* sResizable = (char*)element->Attribute(_RESIZABLE_TAG.c_str());
	char* sLogging = (char*)element->Attribute(_LOGGING_TAG.c_str());

	TiXmlElement* node = element->FirstChildElement(_VENDOR_TAG.c_str()); if(node) sVendor = (char*)node->GetText();
	node = element->FirstChildElement(_VERSION_TAG.c_str()); if(node) sVersion = (char*)node->GetText();
	node = element->FirstChildElement(_RENDERER_TAG.c_str()); if(node) sRenderer = (char*)node->GetText();
	node = element->FirstChildElement(_RENDER_DEVICE_TAG.c_str()); if(node) sRenderDevice = (char*)node->GetText();
	node = element->FirstChildElement(_AUDIO_DEVICE_TAG.c_str()); if(node) sAudioDevice = (char*)node->GetText();
	node = element->FirstChildElement(_TITLE_TAG.c_str()); if(node) sTitle = (char*)node->GetText();
	node = element->FirstChildElement(_FULLSCREEN_TAG.c_str()); if(node) sFullscreen = (char*)node->GetText();
	node = element->FirstChildElement(_RESIZABLE_TAG.c_str()); if(node) sResizable = (char*)node->GetText();
	node = element->FirstChildElement(_LOGGING_TAG.c_str()); if(node) sLogging = (char*)node->GetText();

	int32 x = 0, y = 0, width = 0, height = 0, bitspixel = 0, vrefresh = 0;
	element->Attribute(_POSX_TAG.c_str(), &x);
	node = element->FirstChildElement(_POSX_TAG.c_str()); if(node) x = atoi(node->GetText());
	element->Attribute(_POSY_TAG.c_str(), &y);
	node = element->FirstChildElement(_POSY_TAG.c_str()); if(node) y = atoi(node->GetText());
	element->Attribute(_WIDTH_TAG.c_str(), &width);
	node = element->FirstChildElement(_WIDTH_TAG.c_str()); if(node) width = atoi(node->GetText());
	element->Attribute(_HEIGHT_TAG.c_str(), &height);
	node = element->FirstChildElement(_HEIGHT_TAG.c_str()); if(node) height = atoi(node->GetText());
	element->Attribute(_BITSPIXEL_TAG.c_str(), &bitspixel);
	node = element->FirstChildElement(_BITSPIXEL_TAG.c_str()); if(node) bitspixel = atoi(node->GetText());
	element->Attribute(_VREFRESH_TAG.c_str(), &vrefresh);
	node = element->FirstChildElement(_VREFRESH_TAG.c_str()); if(node) vrefresh = atoi(node->GetText());

	int32 ctpsize = 0, cnpsize = 0, color32 = 0, colpsize = 0, orgpsize = 0, attpsize = 0;
	element->Attribute(_CONTROL_POINT_SIZE_TAG.c_str(), &ctpsize);
	node = element->FirstChildElement(_CONTROL_POINT_SIZE_TAG.c_str()); if(node) ctpsize = atoi(node->GetText());
	char* sctpColor = (char*)element->Attribute(_CONTROL_POINT_COLOR_TAG.c_str());
	node = element->FirstChildElement(_CONTROL_POINT_COLOR_TAG.c_str()); if(node) sctpColor = (char*)node->GetText();
	element->Attribute(_CENTER_POINT_SIZE_TAG.c_str(), &cnpsize);
	node = element->FirstChildElement(_CENTER_POINT_SIZE_TAG.c_str()); if(node) cnpsize = atoi(node->GetText());
	char* scnpColor = (char*)element->Attribute(_CENTER_POINT_COLOR_TAG.c_str());
	node = element->FirstChildElement(_CENTER_POINT_COLOR_TAG.c_str()); if(node) scnpColor = (char*)node->GetText();
	char* scolColor = (char*)element->Attribute(_COLLIDABLE_COLOR_TAG.c_str());
	node = element->FirstChildElement(_COLLIDABLE_COLOR_TAG.c_str()); if(node) scolColor = (char*)node->GetText();
	element->Attribute(_COLLIDABLE_POINT_SIZE_TAG.c_str(), &colpsize);
	node = element->FirstChildElement(_COLLIDABLE_POINT_SIZE_TAG.c_str()); if(node) colpsize = atoi(node->GetText());
	char* scolpColor = (char*)element->Attribute(_COLLIDABLE_POINT_COLOR_TAG.c_str());
	node = element->FirstChildElement(_COLLIDABLE_POINT_COLOR_TAG.c_str()); if(node) scolpColor = (char*)node->GetText();
	element->Attribute(_ORIGIN_POINT_SIZE_TAG.c_str(), &orgpsize);
	node = element->FirstChildElement(_ORIGIN_POINT_SIZE_TAG.c_str()); if(node) orgpsize = atoi(node->GetText());
	char* sorgpColor = (char*)element->Attribute(_ORIGIN_POINT_COLOR_TAG.c_str());
	node = element->FirstChildElement(_ORIGIN_POINT_COLOR_TAG.c_str()); if(node) sorgpColor = (char*)node->GetText();
	element->Attribute(_ATTACHMENT_POINT_SIZE_TAG.c_str(), &attpsize);
	node = element->FirstChildElement(_ATTACHMENT_POINT_SIZE_TAG.c_str()); if(node) attpsize = atoi(node->GetText());
	char* sattpColor = (char*)element->Attribute(_ATTACHMENT_POINT_COLOR_TAG.c_str());
	node = element->FirstChildElement(_ATTACHMENT_POINT_COLOR_TAG.c_str()); if(node) sattpColor = (char*)node->GetText();

	DeviceSettings* sets = new DeviceSettings;
	if(!sets)
		AltoThrow(Exception::ERR_MEMORY);

	if(sVendor)
		sets->vendor = sVendor;
	if(sVersion)
		sets->version = sVersion;
	if(sRenderer)
		sets->renderer = sRenderer;
	if(sRenderDevice)
		sets->renderdevice = sRenderDevice;
	if(sAudioDevice)
		sets->audiodevice = sAudioDevice;
	if(sTitle)
#ifdef UNICODE
	{
		TCHAR wstr[512]; memset(wstr, 0, sizeof(wstr));
		::MultiByteToWideChar(CP_UTF8, 0, sTitle, (int32)strlen(sTitle), wstr, 512);
		sets->title = wstr;
	}
#else
		sets->title = sTitle;
#endif

	sets->x = x;
	sets->y = y;
	sets->width = width;
	sets->height = height;
	sets->bitspixel = bitspixel;
	sets->vrefresh = vrefresh;

	if(sFullscreen)
	{
		if(sFullscreen == _TRUE_TAG)
			sets->fullscreen = true;
		else
			sets->fullscreen = false;
	}

	if(sResizable)
	{
		if(sResizable == _TRUE_TAG)
			sets->resizable = true;
		else
			sets->resizable = false;
	}

	if(sLogging)
	{
		if(sLogging == _TRUE_TAG)
			sets->logging = true;
		else
			sets->logging = false;
	}

	sets->control_point_size = ctpsize;
	if(sctpColor)
	{
		sscanf(sctpColor, "%x", &color32);
		sets->control_point_color = Color::fromUint(color32);
	}

	sets->center_point_size = cnpsize;
	if(scnpColor)
	{
		sscanf(scnpColor, "%x", &color32);
		sets->center_point_color = Color::fromUint(color32);
	}

	if(scolColor)
	{
		sscanf(scolColor, "%x", &color32);
		sets->collidable_color = Color::fromUint(color32);
	}

	sets->collidable_point_size = colpsize;
	if(scolpColor)
	{
		sscanf(scolpColor, "%x", &color32);
		sets->collidable_point_color = Color::fromUint(color32);
	}

	sets->origin_point_size = orgpsize;
	if(sorgpColor)
	{
		sscanf(sorgpColor, "%x", &color32);
		sets->origin_point_color = Color::fromUint(color32);
	}

	sets->attachment_point_size = attpsize;
	if(sattpColor)
	{
		sscanf(sattpColor, "%x", &color32);
		sets->attachment_point_color = Color::fromUint(color32);
	}

	//output settings
	std::cout << _T("vendor : ") << sets->vendor << std::endl;
	std::cout << _T("version : ") << sets->version << std::endl;
	std::cout << _T("renderer : ") << sets->renderer << std::endl;
	std::cout << _T("renderdevice : ") << sets->renderdevice << std::endl;
	std::cout << _T("audiodevice : ") << sets->audiodevice << std::endl;
	std::cout << _T("x : ") << sets->x << std::endl;
	std::cout << _T("y : ") << sets->y << std::endl;
	std::cout << _T("width : ") << sets->width << std::endl;
	std::cout << _T("height : ") << sets->height << std::endl;
	std::cout << _T("bitspixel : ") << sets->bitspixel << std::endl;
	std::cout << _T("fullscreen : ") << sets->fullscreen << std::endl;
	std::cout << _T("resizable : ") << sets->resizable << std::endl;
	std::cout << _T("vrefresh : ") << sets->vrefresh << std::endl;
	std::cout << _T("logging : ") << sets->logging << std::endl;
	std::cout << _T("control point size : ") << sets->control_point_size << std::endl;
	std::cout << _T("control point color : ") << sets->control_point_color << std::endl;
	std::cout << _T("center point size : ") << sets->center_point_size << std::endl;
	std::cout << _T("center point color : ") << sets->center_point_color << std::endl;
	std::cout << _T("collidable color : ") << sets->collidable_color << std::endl;
	std::cout << _T("collidable point size : ") << sets->collidable_point_size << std::endl;
	std::cout << _T("collidable point color : ") << sets->collidable_point_color << std::endl;
	std::cout << _T("origin point size : ") << sets->origin_point_size << std::endl;
	std::cout << _T("origin point color : ") << sets->origin_point_color << std::endl;
	std::cout << _T("attachment point size : ") << sets->attachment_point_size << std::endl;
	std::cout << _T("attachment point color : ") << sets->attachment_point_color << std::endl;

	return sets;
}
